package com.wm.youfangtong

import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import com.umeng.commonsdk.UMConfigure
import com.wm.module_common.umeng.UMParams
import com.wm.module_common.util.DeviceUtil
import com.wm.youfangtong.logic.network.HttpUtil

/**
 * author: wu-meng
 * date  : 2023/12/8
 * desc  : application
 */
class MyApplication : Application() {

    companion object {
        @SuppressLint("StaticFieldLeak")
        lateinit var context: Context
    }

    override fun onCreate() {
        super.onCreate()
        context = applicationContext

        initNetwork()

        initUMSDK()
    }

    /**
     * 初始化网络请求
     */
    private fun initNetwork() {
        HttpUtil.initRetrofit()
    }

    /**
     * 初始化友盟
     */
    private fun initUMSDK() {
        // 友盟预初始化
        UMConfigure.preInit(this,UMParams.appKey,DeviceUtil.getDeviceBrand())

        // 友盟的正式初始化
        UMConfigure.init(this,UMParams.appKey,DeviceUtil.getDeviceBrand(),UMConfigure.DEVICE_TYPE_PHONE,"")

        // 日志开关
        UMConfigure.setLogEnabled(BuildConfig.DEBUG)
    }

}